package com.leetcode;

import java.util.Scanner;

/**
 * TODO
 *
 * @author lefly
 * @version 1.0
 * @classname No125
 * @description https://leetcode-cn.com/problems/valid-palindrome/
 * @date 2021/2/5 下午4:32
 */
public class No125 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean res = isPalindrome(s);
        System.out.println(res);


    }

    public static boolean isPalindrome(String s) {
        if(s == null || s.equals("")){
            return true;
        }
        char[] str = s.toLowerCase().toCharArray();
        int l = 0,r = str.length - 1;
        while (l <= r){
            while (l < r && !isLetter(str[l]) && !isDigital(str[l])){
                l++;
            }
            while (l < r && !isLetter(str[r]) && !isDigital(str[r])){
                r--;
            }
            if(str[l] != str[r]){
                return false;
            }
            l++;
            r--;
        }
        return true;

    }

    public static boolean isLetter(char c){
        return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
    }

    public static boolean isDigital(char c){
        return c >= '0' && c <= '9';
    }



}
